import {
  BwComPropSetConstValueComEnum,
  BwCustomComSoltTypeEnum,
  BwCustomComPropDataTypeEnum,
  BwCustomComEmitParamDataTypeEnum,
} from '../../../render/models'
import type {
  BwCustomComEmitInfoModel,
  BwCustomComSlotInfoModel,
  BwCustomComPropInfoModel,
} from '../../../render/models'

/** 组件属性 */
const comAttrs: Array<BwCustomComPropInfoModel> = [
  {
    key: 'class',
    name: 'classNames',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'model',
    name: '表单数据对象	',
    isRequire: true,
    defaultValue: '{}',
    dataType: [BwCustomComPropDataTypeEnum.object],
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'name',
    name: '表单名称',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '会作为表单字段 id 前缀使用',
  },
  {
    key: 'rules',
    name: '表单验证规则',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.object],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'validateTrigger',
    name: '验证规则触发时机',
    isRequire: false,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
    ],
    defaultValue: 'change',
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'validateOnRuleChange',
    name: '验证规则更新后是否触发验证',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'true',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'disabled',
    name: '组件禁用',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'false',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'colon',
    name: '子项元素是否使用冒号',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'true',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'hideRequiredMark',
    name: '子项必填标识是否隐藏',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'false',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'labelAlign',
    name: '子项标题对齐方式',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: 'left',
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        { value: 'left', label: '左对齐' },
        { value: 'right', label: '右对齐' },
      ],
    }),
    remark: '',
  },
  {
    key: 'labelCol',
    name: '子项标题栅格占位',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.object],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.colSpan,
    constValueSetComProps: undefined,
    remark: '',
  },
  {
    key: 'labelWrap',
    name: '子项标题是否允许换行',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: undefined,
    remark: '',
  },
  {
    key: 'wrapperCol',
    name: '子项控件栅格占位',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.object],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.colSpan,
    constValueSetComProps: undefined,
    remark: '',
  },
]

/** 组件事件 */
const comEmits: Array<BwCustomComEmitInfoModel> = [
  {
    key: 'finish',
    name: '表单提交且数据验证成功后回调事件',
    params: [
      {
        paramKey: 'values',
        paramName: '提交数据',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'finishFailed',
    name: '提交表单且数据验证失败后回调事件',
    params: [
      {
        paramKey: 'params',
        paramName: '回调参数',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '{ values: 表单数据, errorFields: 错误字段集, outOfDate }',
      },
    ],
  },
  {
    key: 'submit',
    name: '提交事件',
    params: [
      {
        paramKey: 'evt',
        paramName: '回调参数',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: 'evt:Event',
      },
    ],
  },
  {
    key: 'validate',
    name: '表单校验事件',
    params: [
      {
        paramKey: 'name',
        paramName: '校验项',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
      {
        paramKey: 'status',
        paramName: '校验状态',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
      {
        paramKey: 'errorMsgs',
        paramName: '校验失败文案',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
    ],
  },
]

/** 组件插槽 */
const comSlots: Array<BwCustomComSlotInfoModel> = [
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'default',
      slotName: '默认插槽',
    },
  },
]

export const antFormInfo = {
  comAttrs,
  comEmits,
  comSlots,
}
